package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements Ioper{
    @Override
    public void work(BookList bookList) {
        if (bookList.isfull()){
            System.out.println("货架已满，暂且无法新增图书！");
            return;
        }
        System.out.println("-新增图书-");
        System.out.println("请输入你要新增图书的信息");
        System.out.println("请依次输入这本书的 书名 作者 价格 类型");
        Scanner sc=new Scanner(System.in);
        Book book=new Book(sc.next(), sc.next(), sc.nextInt(), sc.next());
        int currentSize=bookList.getUsedSize();
        bookList.setBooks(currentSize,book);
        System.out.println("新增成功");
        bookList.setUsedSize(currentSize+1);
    }
}
